<template>
    <!-- 添加或修改镀锌单明细对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="80%" append-to-body :close-on-click-modal="false" v-dialogDrag>
        <el-form ref="form" :model="form" :rules="rules" label-width="120px">
            <el-tabs v-model="activeName" class="detail-tab" type="card">
                <el-tab-pane label="基本信息" name="first">
                    <el-row :gutter="20">
                        <el-col :span="12">
                            <el-form-item label="备注" prop="remark">
                                <el-input v-model="form.remark" placeholder="请输入备注"/>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="发货日期" prop="ddDate">
                                <el-date-picker clearable
                                                v-model="form.ddDate"
                                                type="datetime"
                                                value-format="yyyy-MM-dd HH:mm:ss"
                                                placeholder="请选择发货日期">
                                </el-date-picker>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="需求日期" prop="subDate">
                                <el-date-picker clearable
                                                v-model="form.subDate"
                                                type="datetime"
                                                value-format="yyyy-MM-dd HH:mm:ss"
                                                placeholder="请选择需求日期">
                                </el-date-picker>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="订单金额" prop="money">
                                <el-input v-model="form.money" placeholder="请输入订单金额"/>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="总数量" prop="counts">
                                <el-input v-model="form.counts" placeholder="请输入总数量"/>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="总毛重" prop="dunwei">
                                <el-input v-model="form.dunwei" placeholder="请输入总毛重"/>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="总皮重" prop="pizhong">
                                <el-input v-model="form.pizhong" placeholder="请输入总皮重"/>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="总净重" prop="jingzhong">
                                <el-input v-model="form.jingzhong" placeholder="请输入总净重"/>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="镀锌厂名称" prop="supplierName">
                                <el-input v-model="form.supplierName" placeholder="请输入镀锌厂名称"/>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="镀锌发货过磅单" prop="bangdan">
                                <el-input v-model="form.bangdan" placeholder="请输入镀锌发货过磅单"/>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="镀锌发货清单" prop="qingdan">
                                <el-input v-model="form.qingdan" placeholder="请输入镀锌发货清单"/>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="镀锌回厂榜单" prop="bangdanhui">
                                <el-input v-model="form.bangdanhui" placeholder="请输入镀锌回厂榜单"/>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="镀锌回厂清单" prop="qingdanhui">
                                <el-input v-model="form.qingdanhui" placeholder="请输入镀锌回厂清单"/>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="回厂日期" prop="hcDate">
                                <el-date-picker clearable
                                                v-model="form.hcDate"
                                                type="datetime"
                                                value-format="yyyy-MM-dd HH:mm:ss"
                                                placeholder="请选择回厂日期">
                                </el-date-picker>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="回厂总数量" prop="hcCount">
                                <el-input v-model="form.hcCount" placeholder="请输入回厂总数量"/>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="回厂毛重" prop="hcDunwei">
                                <el-input v-model="form.hcDunwei" placeholder="请输入回厂毛重"/>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="回厂皮重" prop="hcPizhong">
                                <el-input v-model="form.hcPizhong" placeholder="请输入回厂皮重"/>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="回厂净重" prop="hcJingzhong">
                                <el-input v-model="form.hcJingzhong" placeholder="请输入回厂净重"/>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="负责人及电话" prop="fuzeren">
                                <el-input v-model="form.fuzeren" placeholder="请输入负责人及电话"/>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="镀锌厂人及电话" prop="duxinren">
                                <el-input v-model="form.duxinren" placeholder="请输入镀锌厂人及电话"/>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="产品名称" prop="name">
                                <el-input v-model="form.name" placeholder="请输入产品名称"/>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="产品型号" prop="model">
                                <el-input v-model="form.model" placeholder="请输入产品型号"/>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="剩余回厂数量" prop="shengyuCount">
                                <el-input v-model="form.shengyuCount" placeholder="请输入剩余回厂数量"/>
                            </el-form-item>
                        </el-col>
                    </el-row>
                </el-tab-pane>
            </el-tabs>
        </el-form>
        <div slot="footer" class="dialog-footer">
            <el-button type="primary" @click="submitForm">确 定</el-button>
            <el-button @click="cancel">取 消</el-button>
        </div>
    </el-dialog>
</template>

<script>
    import { addAction, getById, updateAction } from '@/api/manage';
    import moment from 'moment';

    export default {
        name: "LvDuxindetailForm",
        data() {
            return {
                // 遮罩层
                loading: true,
                activeName: "first",
                // 弹出层标题
                title: "",
                // 是否显示弹出层
                open: false,
                // 表单参数
                form: {},
                // 表单校验
                rules: {
                },
                url: {
                    getById:'/lvDuxindetail/lvDuxindetail/',
                    add:'/lvDuxindetail/lvDuxindetail/add',
                    edit:'/lvDuxindetail/lvDuxindetail/edit',
                },
            };
        },
        created() {

        },
        methods: {
            // 取消按钮
            cancel() {
                this.open = false;
                this.reset();
            },
            // 表单重置
            reset() {
                this.form = {
            id: null,
            delFlag: null,
            createBy: null,
            createTime: null,
            updateBy: null,
            updateTime: null,
            remark: null,
            ddDate: null,
            subDate: null,
            money: null,
            counts: null,
            dunwei: null,
            pizhong: null,
            jingzhong: null,
            supplierName: null,
            bangdan: null,
            qingdan: null,
            bangdanhui: null,
            qingdanhui: null,
        status: "0",
            type: null,
            hcDate: null,
            hcCount: null,
            hcDunwei: null,
            hcPizhong: null,
            hcJingzhong: null,
            fuzeren: null,
            duxinren: null,
            name: null,
            model: null,
            shengyuCount: null
                };
                this.resetForm("form");
            },
            /** 新增按钮操作 */
            handleAdd() {
                this.reset();
                this.open = true;
                this.title = "添加镀锌单明细";
            },
            /** 修改按钮操作 */
            handleUpdate(row) {
                this.reset();
                const id = row.id || this.ids;
                getById(this.url.getById, id).then(response => {
                    this.form = response.data;
                    this.open = true;
                    this.title = "修改镀锌单明细";
                });
            },
            /** 提交按钮 */
            submitForm() {
                this.$refs["form"].validate(valid => {
                    if (valid) {
                        if (this.form.id != null) {
                            updateAction(this.url.edit, this.form).then(response => {
                                this.$modal.msgSuccess("修改成功");
                                this.open = false;
                                this.$emit('ok');
                            });
                        } else {
                            addAction(this.url.add, this.form).then(response => {
                                this.$modal.msgSuccess("新增成功");
                                this.open = false;
                                this.$emit('ok');
                            });
                        }
                    }
                });
            },
        }
    };
</script>
